<?php
/**
 * 该类用以对各类型字符串等做相关校验
 * 
 * @author Leo
 * @since 2012.2.23
 */
class Helper_Validate
{
    /**
     * 邮箱验证格式是否正确
     * 
     * @param string $email 
     * @return string
     */
    public static function emailCheck( $email )
    {
        if( !filter_var( $email , FILTER_VALIDATE_EMAIL) )
        {
           throw new AppException( 2001 , $email );
        }
        
        return $email;
    }
    
    /**
     * 验证密码是否达到最小长度
     * 
     * @param string $password      密码字符串
     * @return string
     */
    public static function passwordCheck( $password )
    {
        $password = trim( $password );
        if( strlen( $password ) < 2 )
        {
            throw new AppException( 2002 );
        }
        
        return $password;
    }
}
?>
